<template>
    <div>
      <h2 style="color: grey">企业信息</h2><br>

      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="企业名称查询">
          <el-input v-model="formInline.compselname" placeholder="企业名称"></el-input>
        </el-form-item>
        <el-form-item label="招聘联系人查询:">
          <el-input v-model="formInline.compselcontact" placeholder="招聘联系人"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="selectAlltea">查询</el-button>
        </el-form-item>
      </el-form>

      <el-table
        :data="tableData"
        border
        style="width:95%;margin-left:auto;margin-right: auto"
        fit
        @row-click="selectCompInfo"
        
      >
        <el-table-column
          prop="comp_code"
          label="信用代码"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="comp_name"
          label="企业名称"
          align="center"
        >
        </el-table-column>

        <el-table-column
          prop="comp_contact"
          label="招聘联系人"
          align="center"
        >
        </el-table-column>

        <el-table-column
          prop="comp_contacttel"
          label="联系电话"
          align="center"
        >
        </el-table-column>

        <el-table-column
          prop="comp_email"
          label="电子邮箱"
          align="center"
        >
        </el-table-column>


        <el-table-column
          prop="u_acount"
          label="系统账号"
          align="center"
        >
        </el-table-column>

        <el-table-column
          label="操作"
          align="center"
          prop="u_status"
        >
          　<template slot-scope="scope">
          　　　  <span v-if="scope.row.u_status== '1'">
                      <el-button type="primary" plain @click="alertStuInfo">详情</el-button>
                      <el-button type="danger" plain @click="disableStuInfo" >禁用</el-button>
                   </span>
          　　　  <span v-if="scope.row.u_status== '2'">
                       <el-button type="primary" plain @click="alertStuInfo">详情</el-button>
                      <el-button type="danger" plain @click="enableStuInfo" >启用</el-button>
                 </span>
          　　　</template>
        </el-table-column>

      </el-table>
    </div>
</template>

<style>
    body {
        background-color: #F5F5F5;
    }
</style>

<script>
    export default {
      name:'compAllInfo',
        data() {
            return {
              tableData: [
              ],
              stu_code:'',
              u_status:'',
              u_acount:'',
              formInline: {
                compselname: '',
                compselcontact: '',
              }
            }
        },
      created() {
        this.selectAlltea();
      },
      methods: {
        selectAlltea:function () {
          this.$axios({
            url: `/api/manOperat/selectAllcomp/`+"?comp_name=" + this.formInline.compselname+"&comp_contact="+this.formInline.compselcontact,
            method: 'get',
          }).then(complist => {  // 请求成功
            this.tableData = complist.data;

          }).catch(error => {  // 请求失败

          });
          
        },
        selectCompInfo: function (teainfo) {
          this.$axios({
            url: `/api/manOperat/selectCompByCode/` + "?u_acount=" + teainfo.u_acount,
            method: 'get',
          }).then(teaInfoByCode => {  // 请求成功
            this.u_acount = teaInfoByCode.data[0].u_acount;
          }).catch(error => {  // 请求失败

          });
        },

        disableStuInfo:function(){
          this.$axios({
            url: `/api/manOperat/disableUser/`+"?u_acount="+this.u_acount,
            method: 'get',
          }).then(loginOut => {  // 请求成功
            console.log('请求成功');
            console.log(loginOut.data);
            alert(loginOut.data);
            location.reload();
          }).catch(error => {  // 请求失败
          });

        },
        enableStuInfo:function () {
          this.$axios({
            url: `/api/manOperat/enableUser/`+"?u_acount="+this.u_acount,
            method: 'get',
          }).then(loginOut => {  // 请求成功
            console.log('请求成功');
            console.log(loginOut.data);
            alert("启用成功!");
            location.reload();
          }).catch(error => {  // 请求失败
          });
        },
        onSubmit() {
          console.log('submit!');
        }


      }
    }
</script>
